package com.olap.starter.common.vo;

import com.olap.starter.common.vo.Parameter;
import com.olap.starter.common.vo.QueryParameter;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Data
@Slf4j
public class DictTagVO {
    String dbName;
    String tableName;
    String label;
    String value;
    private List<String> orderBy; //排序
    private List<String> groupBy; //分组
    private List<Parameter> whereAnd; //and
    private List<Parameter> whereOr; //and
    public String getSQL() {
        StringBuilder sql = new StringBuilder();
        sql.append(" select ");
        sql.append(label);
        sql.append(" AS dictLabel,");
        sql.append(value);
        sql.append(" AS dictValue from ");
        sql.append(tableName);
        return sql.toString();
    }
    public QueryParameter getQueryParameter() {
        QueryParameter queryParameter = new QueryParameter();
        queryParameter.setSql(getSQL() );
        queryParameter.setOrderBy(orderBy);
        queryParameter.setGroupBy(groupBy);
        queryParameter.setQueryParameterListAnd(whereAnd);
        queryParameter.setQueryParameterListOr(whereOr);
        queryParameter.setEnablePage(true);
        queryParameter.setPageSize(100);
        return queryParameter;
    }
}
